import Layout from '@/views/layout/Layout';

// 控制这系列页面的权限
const authData = {
  Contract: ['crm:contract:'], // 合同审批
  ContractManagement: ['crm:contractManage:'], // 合同管理
  Original: ['crm:original:']
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}

// 合同
const contractRouter = [
  {
    path: '/legal',
    component: Layout,
    redirect: '/legal/index',
    name: 'legal',
    meta: { title: '法务', icon: 'sidebar-contract', authControl: pageAllAuth },
    children: [
      {
        path: 'index',
        name: 'ContractManagement',
        component: () => import('@/views/legal/index'),
        meta: { title: '合同审批', authControl: authData.Contract, keepAlive: true, isChange: true, headerBarShow: false }
      },
      {
        path: 'manageIndex',
        name: 'ContractManagementHistory',
        component: () => import('@/views/legal/manageIndex'),
        meta: { title: '合同管理', authControl: authData.ContractManagement, keepAlive: true, isChange: true, headerBarShow: false }
      },
      {
        path: 'originIndex',
        name: 'original',
        component: () => import('@/views/original/index'),
        meta: { title: '申请原件', authControl: authData.Original, keepAlive: true, isChange: true, headerBarShow: false }
      },
      /**
       * 内页
       */
      /** 合同审批内页 */
      {
        path: 'contractUpload',
        component: () => import('@/views/legal/upload/index'),
        name: 'contractUpload',
        meta: { title: '文件上传', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/legal/index' },
        hidden: true
      },
      {
        path: 'createContract',
        name: 'CreateContract',
        hidden: true,
        component: () => import('@/views/legal/create/index'),
        meta: { title: '合同审批', headerBarShow: true, activeMenu: '/legal/index' } // headerBarShow 为true显示头像
      }, {
        path: 'editContract/:id',
        name: 'EditContract',
        hidden: true,
        component: () => import('@/views/legal/create/index'),
        meta: { title: '合同审批', headerBarShow: true, activeMenu: '/legal/index' } // headerBarShow 为true显示头像
      }, {
        path: 'contractDetail/:id',
        name: 'contractDetail',
        hidden: true,
        component: () => import('@/views/legal/detail/index'),
        meta: { title: '合同详情', headerBarShow: true, activeMenu: '/legal/index' } // headerBarShow 为true显示头像
      }, {
        path: 'contractDiff/:id',
        name: 'contractDiff',
        hidden: true,
        component: () => import('@/views/legal/detail/module/contractDiff'),
        meta: { title: '合同差异对比', headerBarShow: true, activeMenu: '/legal/index' } // headerBarShow 为true显示头像
      }, {
        path: 'hisContractDetail/:id',
        name: 'hisContractDetail',
        hidden: true,
        component: () => import('@/views/legal/detail/index'),
        meta: { title: '历史合同详情', headerBarShow: true, activeMenu: '/legal/manageIndex' } // headerBarShow 为true显示头像
      }, {
        path: 'hisCreateContract',
        name: 'hisCreateContract',
        hidden: true,
        component: () => import('@/views/legal/create/index'),
        meta: { title: '历史合同审批', headerBarShow: true, activeMenu: '/legal/manageIndex' } // headerBarShow 为true显示头像
      }, {
        path: 'hisEditContract/:id',
        name: 'hisEditContract',
        hidden: true,
        component: () => import('@/views/legal/create/index'),
        meta: { title: '历史合同审批', headerBarShow: true, activeMenu: '/legal/manageIndex' } // headerBarShow 为true显示头像
      },
      {
        path: 'originalCreate',
        name: 'originalCreate',
        hidden: true,
        component: () => import('@/views/original/create/index'),
        meta: { title: '申请原件', headerBarShow: true, activeMenu: '/legal/originIndex' } // headerBarShow 为true显示头像
      },
      {
        path: 'originalEdit',
        name: 'originalEdit',
        hidden: true,
        component: () => import('@/views/original/create/index'),
        meta: { title: '申请原件', headerBarShow: true, activeMenu: '/legal/originIndex' } // headerBarShow 为true显示头像
      },
      {
        path: 'originalDetail',
        name: 'originalDetail',
        hidden: true,
        component: () => import('@/views/original/detail/index'),
        meta: { title: '申请原件详情', headerBarShow: true, activeMenu: '/legal/originIndex' } // headerBarShow 为true显示头像
      }
    ]
  }
];
export default contractRouter;
